const express = require("express");
const app = express();

app.get("/", (req, res) => {
  console.log(req.url);
  console.log(req.method);
  console.log(req.headers);
  console.log("请求参数", req.query);

  // 设置响应状态码
  res.statusCode = 201;
  res.cookie("foo", "bar");
  res.cookie("a", 123);
  // 结束响应
  res.end("hello world");
  // res.send("Hello World");
});

app.post("/", (req, res) => {
  res.send("post /");
});

app.put("/user", (req, res) => {
  res.send("put user");
});

app.delete("/user", (req, res) => {
  res.send("delete user");
});

app.listen(3000, () => {
  console.log("server is running at http://localhost:3000");
});
